/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var PresentationController = new Class({
    
    lfc: null,
    dfc: null,
    
    initialize: function(options){
        this.lfc = options.lfc;
        this.dfc = options.dfc;
    },
    
    start: function(){      
        var mainLoop = function(frame){  
            //remove events
            frame.removeEvents();
            //console.log('layout frame:'+frame);
            frame.setHasSibling(this.lfc.countFrames() > 1);
            //add events
            frame.addEvent('timelineEnd', function(frame){
                frame.removeEvents('timelineEnd');
                //console.log('Layoutframe endTimeline');
                frame.unbindDataFrames();                
                //keep loop going
                this.lfc.shift();
                mainLoop(this.lfc.getCurrentFrame());
            }.bind(this));
            frame.addEvent('contentLoaded', function(frame){
                //frame.removeEvents('contentLoaded');
                frame.bindDataFrames(this.dfc.getFrames());                  
                frame.render();                
            }.bind(this));
            //load frame
            frame.load($('screen'));                         
        }.bind(this);
        mainLoop(this.lfc.getFirstFrame());        
    }
});


